// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.brest.managesambafilesharing;

import android.content.Context;

// Referenced classes of package com.funkyfresh.samba:
//            LOG, FileOps, SambaInfo, SambaWifiInfo

public class WifiWhitelist {

	public WifiWhitelist() {
	}

	/*
	 * public static final boolean BssidIsWhitelisted(String s) { boolean flag =
	 * true; if(s != null && s.length() >= 10) goto _L2; else goto _L1 _L1:
	 * LOG.e((new StringBuilder("bad bssid format:")).append(s).toString());
	 * flag = false; _L4: return flag; _L2: String as[][]; int i; as =
	 * ReadWifiWhitelist(); if(as == null || as.length < flag) { flag = false;
	 * continue; } i = 0; _L5: if(i < as.length) continue; LOG.i((new
	 * StringBuilder
	 * (String.valueOf(s))).append(" not found in wifi whitelist").toString());
	 * flag = false; if(true) goto _L4; else goto _L3 _L3: i++; goto _L5
	 * if(!validateWifiWhitelistEntry(as[i]) ||
	 * !as[i][flag].equalsIgnoreCase(s)) goto _L3; else goto _L4 }
	 * 
	 * public static final String[][] ReadWifiWhitelist() { String as[][];
	 * String as1[]; as = null; as1 =
	 * FileOps.readFile("/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf"
	 * ); if(as1 != null && as1.length >= 1) goto _L2; else goto _L1 _L1:
	 * LOG.i((new
	 * StringBuilder("whitelist file is empty or non-existant.  fileExists="
	 * )).append(FileOps.fileExists(
	 * "/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf")).toString());
	 * _L4: return as; _L2: StringBuilder stringbuilder; int i; stringbuilder =
	 * new StringBuilder(); i = 0; _L5: label0: { if(i < as1.length) break
	 * label0; String as2[]; if(stringbuilder == null ||
	 * stringbuilder.toString().split("\\n").length < 1) {
	 * LOG.i("wifi white list contains no valid entries"); } else { String as3[]
	 * = stringbuilder.toString().split("\\n"); as =
	 * (String[][])Array.newInstance(java/lang/String, new int[] { as3.length, 3
	 * }); int j = 0; while(j < as3.length) { as[j] = as3[j].split("\\|"); j++;
	 * } } } if(true) goto _L4; else goto _L3 _L3: if(as1[i] == null) {
	 * LOG.e((new
	 * StringBuilder("whiteListFile[")).append(i).append("] entry is null. Skipping"
	 * ).toString()); } else { as2 = as1[i].split("\\|"); if(as2 == null ||
	 * as2.length != 3 || !validateWifiWhitelistEntry(as2)) { LOG.i((new
	 * StringBuilder
	 * ("ignoring invalid format whitelist file entry: ")).append(as1
	 * [i]).toString()); } else { if(as2[2].length() > 25) { as2[2] =
	 * as2[2].substring(0, 24); as1[i] = (new
	 * StringBuilder(String.valueOf(as2[0]
	 * ))).append("|").append(as2[1]).append("|").append(as2[2]).toString(); }
	 * stringbuilder.append((new
	 * StringBuilder(String.valueOf(as1[i]))).append("\n").toString()); } } i++;
	 * goto _L5 }
	 * 
	 * public static final boolean WriteWifiWhitelist(String as[][]) { boolean
	 * flag = false; if(as != null && as.length >= 1) goto _L2; else goto _L1
	 * _L1: LOG.i((new
	 * StringBuilder("deleting whitelist file, received a null/empty array "
	 * )).append(as).toString());
	 * FileOps.rmFile("/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf"
	 * ); _L4: return flag; _L2: StringBuilder stringbuilder; int i;
	 * stringbuilder = new StringBuilder(); i = 0; _L5: label0: { if(i <
	 * as.length) break label0; if(stringbuilder == null ||
	 * stringbuilder.toString().split("\\n").length < 1) {
	 * LOG.i("wifi white list contents to write ar empty. will remove the file"
	 * );
	 * FileOps.readFile("/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf"
	 * ); flag = true; } else if(!FileOps.writeFile(
	 * "/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf",
	 * stringbuilder.toString().split("\\n"))) LOG.e(
	 * "Error writing wifiWhitelistFile: /data/data/com.funkyfresh.samba/files/wifiWhitelist.conf"
	 * ); else flag = true; } if(true) goto _L4; else goto _L3 _L3: if(as[i] ==
	 * null || as[i].length != 3 || !validateWifiWhitelistEntry(as[i])) {
	 * LOG.i((new
	 * StringBuilder("not writing invalid whitelist entry for entry: enabled="
	 * )).
	 * append(as[i][0]).append("  bssid=").append(as[i][1]).append("  ssid=").
	 * append(as[i][2]).toString()); } else { if(as[i][2].length() > 25)
	 * as[i][2] = as[i][2].substring(0, 24); stringbuilder.append((new
	 * StringBuilder
	 * (String.valueOf(as[i][0]))).append("|").append(as[i][1]).append
	 * ("|").append(as[i][2]).append("\n").toString()); } i++; goto _L5 }
	 * 
	 * public static final void handleWhiteListChanges(Context context) {
	 * if(!(new SambaInfo(context)).passwdNotSet()) goto _L2; else goto _L1 _L1:
	 * return; _L2: SambaWifiInfo sambawifiinfo = new SambaWifiInfo(context);
	 * if(sambawifiinfo.managedWifiIsUp()) { boolean flag =
	 * SambaInfo.sambaIsRunning(); String s = sambawifiinfo.getWifiSsid();
	 * String s1 = sambawifiinfo.getWifiBssid(); SharedPreferences
	 * sharedpreferences =
	 * PreferenceManager.getDefaultSharedPreferences(context); boolean flag1 =
	 * sharedpreferences.getBoolean("WifiWhitelistEnabled", false);
	 * sharedpreferences.getBoolean("WhiteListAllowManualStart", true); boolean
	 * flag2 = BssidIsWhitelisted(s1); View view = View.inflate(context,
	 * 0x7f030001, null); TextView textview =
	 * (TextView)view.findViewById(0x7f0a0001);
	 * textview.setMovementMethod(LinkMovementMethod.getInstance());
	 * textview.setClickable(false); textview.setLongClickable(false);
	 * textview.setLinksClickable(true); ctx = context;
	 * android.app.AlertDialog.Builder builder = new
	 * android.app.AlertDialog.Builder(context); builder.setView(view);
	 * builder.setIcon(0x7f020000); builder.setTitle("Wifi White List");
	 * if(flag1) if(!flag2 && flag) { textview.setText((new
	 * StringBuilder(String.
	 * valueOf(""))).append("The connected Access Point:\n\n"
	 * ).append(s).append("\n").append(s1).append(
	 * "\n\nis not a member of the Wifi White List.\n\nPress 'Stop' to stop filesharing on this Access Point now, or 'Ignore' to keep filesharing running on this Access Point for now."
	 * ).toString()); builder.setNegativeButton("Ignore", null);
	 * builder.setPositiveButton("Stop", new
	 * android.content.DialogInterface.OnClickListener() {
	 * 
	 * public void onClick(DialogInterface dialoginterface, int i) { Intent
	 * intent = new Intent();
	 * intent.setAction("com.funkyfresh.samba.STOPSAMBA");
	 * WifiWhitelist.ctx.sendBroadcast(intent); }
	 * 
	 * } ); builder.show(); } else if(flag2 && !flag) { textview.setText((new
	 * StringBuilder
	 * (String.valueOf(""))).append("The connected Access Point:\n\n"
	 * ).append(s).append("\n").append(s1).append(
	 * "\n\nis part of the White List.\n\nPress 'Start' to start filesharing now, or 'Ignore' to leave filesharing off for this Access Point for now."
	 * ).toString()); builder.setNegativeButton("Ignore", null);
	 * builder.setPositiveButton("Start", new
	 * android.content.DialogInterface.OnClickListener() {
	 * 
	 * public void onClick(DialogInterface dialoginterface, int i) {
	 * android.content.SharedPreferences.Editor editor =
	 * PreferenceManager.getDefaultSharedPreferences(WifiWhitelist.ctx).edit();
	 * editor.putString("sambaenabled", "YES"); editor.commit(); Intent intent =
	 * new Intent(); intent.setAction("com.funkyfresh.samba.RESTARTSAMBA");
	 * WifiWhitelist.ctx.sendBroadcast(intent); }
	 * 
	 * } ); builder.show(); } } if(true) goto _L1; else goto _L3 _L3: }
	 * 
	 * public static final boolean handleWifiWhiteListEdit(Context context) {
	 * View view; TableLayout tablelayout; LayoutInflater layoutinflater; int i;
	 * SambaWifiInfo sambawifiinfo = new SambaWifiInfo(context);
	 * existingWifiWhitelist = ReadWifiWhitelist(); boolean flag =
	 * sambawifiinfo.managedWifiIsUp(); String s = sambawifiinfo.getWifiSsid();
	 * String s1 = sambawifiinfo.getWifiBssid(); wifiWhitelistEditorValues =
	 * (String[][])Array.newInstance(java/lang/String, new int[] { 20, 3 });
	 * view = View.inflate(context, 0x7f030002, null); tablelayout =
	 * (TableLayout)view.findViewById(0x7f0a0003); layoutinflater =
	 * (LayoutInflater)context.getSystemService("layout_inflater"); i = 0;
	 * if(flag && s != null && s1 != null && !BssidIsWhitelisted(s1) &&
	 * (existingWifiWhitelist == null || existingWifiWhitelist != null &&
	 * existingWifiWhitelist.length < 20)) { wifiWhitelistEditorValues[0][0] =
	 * "0"; wifiWhitelistEditorValues[0][1] = s1;
	 * wifiWhitelistEditorValues[0][2] = s; i = 0 + 1; }
	 * if(existingWifiWhitelist == null || existingWifiWhitelist.length <= 0)
	 * goto _L2; else goto _L1 _L1: int k = 0; _L6: if(k <
	 * existingWifiWhitelist.length) goto _L3; else goto _L2 _L2:
	 * android.app.AlertDialog.Builder builder; boolean flag1; if(i < 1) {
	 * ((TableRow)view.findViewById(0x7f0a0004)).setVisibility(0);
	 * ((TextView)view.findViewById(0x7f0a0005)).setText(
	 * "Wifi does not appear to be associated with any access point at the moment, and the whitelist does not contain any other entries of permitted access points.\n\nTo add a wifi access point to this whitelist, establish a wifi connection to the access point then return to this menu and it should be available for selection to add."
	 * ); ((TableRow)view.findViewById(0x7f0a0006)).setVisibility(8); } else {
	 * if(i == 20 && existingWifiWhitelist.length == 20) {
	 * ((TableRow)view.findViewById(0x7f0a0004)).setVisibility(0);
	 * ((TextView)view.findViewById(0x7f0a0005)).setText(
	 * "NOTE: Maximum number of entries (20) has been reached.  You will need to delete an existing entry before another can be added."
	 * ); } TextView textview = (TextView)view.findViewById(0x7f0a0007);
	 * SpannableString spannablestring = new
	 * SpannableString(context.getText(0x7f07000d)); spannablestring.setSpan(new
	 * UnderlineSpan(), 0, spannablestring.length(), 0);
	 * textview.setText(spannablestring); TextView textview1 =
	 * (TextView)view.findViewById(0x7f0a0008); SpannableString spannablestring1
	 * = new SpannableString(context.getText(0x7f07000e));
	 * spannablestring1.setSpan(new UnderlineSpan(), 0,
	 * spannablestring1.length(), 0); textview1.setText(spannablestring1); int j
	 * = 0; while(j < i) { if(j > 0)
	 * tablelayout.addView((TableRow)layoutinflater.inflate(0x7f030004,
	 * tablelayout, false)); TableRow tablerow =
	 * (TableRow)layoutinflater.inflate(0x7f030005, tablelayout, false);
	 * ((TextView
	 * )tablerow.findViewById(0x7f0a001c)).setText(wifiWhitelistEditorValues
	 * [j][2]); ((TextView)tablerow.findViewById(0x7f0a001d)).setText(
	 * wifiWhitelistEditorValues[j][1]); CheckBox checkbox =
	 * (CheckBox)tablerow.findViewById(0x7f0a001e); checkbox.setId(j + 1000);
	 * if(wifiWhitelistEditorValues[j][0].equals("0"))
	 * checkbox.setChecked(false); else checkbox.setChecked(true);
	 * checkbox.setOnCheckedChangeListener(new
	 * android.widget.CompoundButton.OnCheckedChangeListener() {
	 * 
	 * public void onCheckedChanged(CompoundButton compoundbutton, boolean
	 * flag2) { int l = compoundbutton.getId(); if(flag2)
	 * WifiWhitelist.wifiWhitelistEditorValues[l - 1000][0] = "1"; else
	 * WifiWhitelist.wifiWhitelistEditorValues[l - 1000][0] = "0"; }
	 * 
	 * } ); tablelayout.addView(tablerow); j++; } } builder = new
	 * android.app.AlertDialog.Builder(context);
	 * builder.setTitle("Wifi White List Editor"); builder.setIcon(0x7f020000);
	 * builder.setView(view); if(i == 0) { builder.setNegativeButton(0x104000a,
	 * null); builder.show(); flag1 = true; } else { ctx = context;
	 * wifiWhitelistEditorLength = i; builder.setNegativeButton(0x1040000,
	 * null); builder.setPositiveButton("Save", new
	 * android.content.DialogInterface.OnClickListener() {
	 * 
	 * public void onClick(DialogInterface dialoginterface, int l) { String
	 * as[][] = (String[][])Array.newInstance(java/lang/String, new int[] {
	 * WifiWhitelist.wifiWhitelistEditorLength, 3 }); int i1 = 0; do { if(i1 >=
	 * WifiWhitelist.wifiWhitelistEditorLength) {
	 * if(!WifiWhitelist.WriteWifiWhitelist(as))
	 * LOG.e("WriteWifiWhitelist returned false");
	 * WifiWhitelist.handleWhiteListChanges(WifiWhitelist.ctx); return; }
	 * as[i1][0] = "1";
	 * if(WifiWhitelist.wifiWhitelistEditorValues[i1][0].equals("1")) as[i1][1]
	 * = WifiWhitelist.wifiWhitelistEditorValues[i1][1]; else as[i1][1] =
	 * "_delete_me_"; as[i1][2] =
	 * WifiWhitelist.wifiWhitelistEditorValues[i1][2]; i1++; } while(true); }
	 * 
	 * } ); builder.show(); flag1 = true; } return flag1; _L3:
	 * wifiWhitelistEditorValues[i][0] = "1"; wifiWhitelistEditorValues[i][1] =
	 * existingWifiWhitelist[k][1]; wifiWhitelistEditorValues[i][2] =
	 * existingWifiWhitelist[k][2]; if(++i == 20) goto _L2; else goto _L4 _L4:
	 * k++; if(true) goto _L6; else goto _L5 _L5: }
	 * 
	 * private static final boolean validateWifiWhitelistEntry(String as[]) {
	 * boolean flag = false; if(as == null || as.length != 3) LOG.e((new
	 * StringBuilder("error: wlEntry='")).append(as).append("'").toString());
	 * else if(as[0] == null || !as[0].equals("0") && !as[0].equals("1"))
	 * LOG.e((new
	 * StringBuilder("error: wlEntry[0] is not a 0 or 1: wlEntry[0]=")
	 * ).append(as
	 * [0]).append(",wlEntry[0].length()=").append(as[0].length()).toString());
	 * else if(as[1] == null) LOG.e((new
	 * StringBuilder("error: wlEntry[1] null: wlEntry='"
	 * )).append(as[1]).append("'").toString()); else
	 * if(!Pattern.compile("^([A-Za-z\\d]{2}:){5}[A-Za-z\\d]{2}$"
	 * ).matcher(as[1]).matches()) LOG.e((new
	 * StringBuilder("error: wlEntry[1] not BSSID/MAC address format: wlEntry[1]="
	 * )).append(as).toString()); else if(as[2] == null || as.length < 1)
	 * LOG.e((new
	 * StringBuilder("error: wlEntry[2] not valid string: wlEntry[2]="
	 * )).append(as[2]).toString()); else flag = true; return flag; }
	 */
	private static Context ctx;
	private static String existingWifiWhitelist[][];
	public static final int maxSsidLength = 25;
	private static final int wifiWhitelistEditorIDStart = 1000;
	private static int wifiWhitelistEditorLength = 0;
	private static String wifiWhitelistEditorValues[][];
	private static final String wifiWhitelistFile = "/data/data/com.funkyfresh.samba/files/wifiWhitelist.conf";

}
